﻿' ------------------------------------------------------------------------------
' These utilities create Open GIS Consortion (OGC) well-known text (WKT)
' representations of geometric and geographic points. See the discussion
' in Enums.vb for the coordinate ordering issues for WKT geography.
' ------------------------------------------------------------------------------
' This file is part of the SQL Server 2008 Technology Demonstration. This
' application was designed and coded by Eric Weitzman, LandTime Inc, for
' Microsoft Corporation. Contact Ed Katibah at Microsoft about this demo.
' Copyright © 2008 Microsoft Corporation. All rights reserved.
' ------------------------------------------------------------------------------

Public Module SpatialUtils

    ' Create an OGC well-known text representation of a geometry point

    Public Function CreateWktGeometryPoint(ByVal x As Double, ByVal y As Double) As String
        Return String.Format("POINT ({0} {1})", x, y)
    End Function

    ' Create an OGC well-known text representation of a geographic point

    Public Function CreateWktGeographyPoint(ByVal longitude As Double, ByVal latitude As Double, ByVal order As EnumCoordinateOrder) As String
        If order = EnumCoordinateOrder.eLongitudeLatitude Then
            Return String.Format("POINT ({0} {1})", longitude, latitude)
        Else
            Return String.Format("POINT ({0} {1})", latitude, longitude)
        End If
    End Function

End Module
